//package com.yunhe.device.controller.base;
//
//import com.yunhe.device.domain.base.DeviceType;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.device.service.base.DeviceTypeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 设备类型Controller
// * @author liuronglei
// */
//@Api(value = "deviceType", description = "设备类型", tags = {"Base_DeviceType"})
//@RestController
//@RequestMapping("/types/device")
//public class DeviceTypeController {
//    @Autowired
//    private DeviceTypeService deviceTypeService;
//
//    /**
//     * 新增设备类型
//     * @param deviceType 设备类型对象
//     */
//    @ApiOperation("新增设备类型")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DeviceType deviceType)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        DeviceType newDeviceType = deviceTypeService.createDeviceType(deviceType);
//        return new ResponseEntity<>(new ResultObject<>(newDeviceType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除设备类型
//     * @param id 设备类型ID
//     */
//    @ApiOperation("根据ID删除设备类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        deviceTypeService.deleteDeviceType(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新设备类型
//     * @param id 设备类型ID
//     * @param deviceType 设备类型对象
//     */
//    @ApiOperation("更新设备类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody DeviceType deviceType)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        deviceType.setId(id);
//        DeviceType newDeviceType = deviceTypeService.updateDeviceType(deviceType);
//        return new ResponseEntity<>(new ResultObject<>(newDeviceType), HttpStatus.OK);
//    }
//
//    /**
//     * 更新设备类型
//     * @param id 设备类型ID
//     * @param code 设备类型代码
//     * @param name 设备类型编号
//     * @param title 设备类型名称
//     * @param sn 排序序号
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新设备类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备类型ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "设备类型代码", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "设备类型编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "设备类型名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "sn", value = "排序序号", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "boolean", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title,
//            @RequestParam("sn") Optional<Long> sn,
//            @RequestParam("activity") Optional<Boolean> activity)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        DeviceType newDeviceType = deviceTypeService.updateDeviceType(id, code.orElse(null), name.orElse(null), title.orElse(null), sn.orElse(null), activity.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newDeviceType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备类型ID获得设备类型
//     * @param id 设备类型ID
//     */
//    @ApiOperation("根据设备类型ID获得设备类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "设备类型ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        DeviceType deviceType = deviceTypeService.findByDeviceTypeId(id);
//        return new ResponseEntity<>(new ResultObject<>(deviceType), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得设备类型列表
//     */
//    @ApiOperation("根据条件获得设备类型列表")
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search() {
//        Iterable<DeviceType> results = deviceTypeService.findDeviceTypes();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 根据设备代码获得设备类型
//     * @param devCode 设备代码
//     */
//    @ApiOperation("根据设备代码获得设备类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "devCode", value = "设备代码", required = true, dataType = "long", paramType = "query")
//    })
//    @RequestMapping(value = "/byDevCode", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> searchByDevCode(
//            @RequestParam("devCode") Long devCode) {
//        DeviceType result = deviceTypeService.findDeviceTypeByDevCode(devCode);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//}